using System; 
using System.Text; 
using System.Data;
using System.Data.SqlClient;
using System.Data.Common;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Configuration; 
using System.Xml; 
using System.Xml.Serialization;
using SubSonic; 
using SubSonic.Utilities;

namespace Adex
{
	/// <summary>
	/// Strongly-typed collection for the CommercialLog class.
	/// </summary>
	[Serializable]
	public partial class CommercialLogCollection : ActiveList<CommercialLog, CommercialLogCollection> 
	{	   
		public CommercialLogCollection() {}

	}

	/// <summary>
	/// This is an ActiveRecord class which wraps the CommercialLog table.
	/// </summary>
	[Serializable]
	public partial class CommercialLog : ActiveRecord<CommercialLog>
	{
		#region .ctors and Default Settings
		
		public CommercialLog()
		{
		  SetSQLProps();
		  InitSetDefaults();
		  MarkNew();
		}

		
		private void InitSetDefaults() { SetDefaults(); }

		
		public CommercialLog(bool useDatabaseDefaults)
		{
			SetSQLProps();
			if(useDatabaseDefaults)
				ForceDefaults();
			MarkNew();
		}

		public CommercialLog(object keyID)
		{
			SetSQLProps();
			InitSetDefaults();
			LoadByKey(keyID);
		}

		 
		public CommercialLog(string columnName, object columnValue)
		{
			SetSQLProps();
			InitSetDefaults();
			LoadByParam(columnName,columnValue);
		}

		
		protected static void SetSQLProps() { GetTableSchema(); }

		
		#endregion
		
		#region Schema and Query Accessor
		public static Query CreateQuery() { return new Query(Schema); }

		
		public static TableSchema.Table Schema
		{
			get
			{
				if (BaseSchema == null)
					SetSQLProps();
				return BaseSchema;
			}

		}

		
		private static void GetTableSchema() 
		{
			if(!IsSchemaInitialized)
			{
				//Schema declaration
				TableSchema.Table schema = new TableSchema.Table("CommercialLog", TableType.Table, DataService.GetInstance("Adex"));
				schema.Columns = new TableSchema.TableColumnCollection();
				schema.SchemaName = @"dbo";
				//columns
				
				TableSchema.TableColumn colvarCommercialLogID = new TableSchema.TableColumn(schema);
				colvarCommercialLogID.ColumnName = "CommercialLogID";
				colvarCommercialLogID.DataType = DbType.Int64;
				colvarCommercialLogID.MaxLength = 0;
				colvarCommercialLogID.AutoIncrement = true;
				colvarCommercialLogID.IsNullable = false;
				colvarCommercialLogID.IsPrimaryKey = true;
				colvarCommercialLogID.IsForeignKey = false;
				colvarCommercialLogID.IsReadOnly = false;
				colvarCommercialLogID.DefaultSetting = @"";
				colvarCommercialLogID.ForeignKeyTableName = "";
				schema.Columns.Add(colvarCommercialLogID);
				
				TableSchema.TableColumn colvarCountryID = new TableSchema.TableColumn(schema);
				colvarCountryID.ColumnName = "CountryID";
				colvarCountryID.DataType = DbType.Byte;
				colvarCountryID.MaxLength = 0;
				colvarCountryID.AutoIncrement = false;
				colvarCountryID.IsNullable = true;
				colvarCountryID.IsPrimaryKey = false;
				colvarCountryID.IsForeignKey = true;
				colvarCountryID.IsReadOnly = false;
				colvarCountryID.DefaultSetting = @"";
				
					colvarCountryID.ForeignKeyTableName = "Country";
				schema.Columns.Add(colvarCountryID);
				
				TableSchema.TableColumn colvarRFDate = new TableSchema.TableColumn(schema);
				colvarRFDate.ColumnName = "RFDate";
				colvarRFDate.DataType = DbType.DateTime;
				colvarRFDate.MaxLength = 0;
				colvarRFDate.AutoIncrement = false;
				colvarRFDate.IsNullable = true;
				colvarRFDate.IsPrimaryKey = false;
				colvarRFDate.IsForeignKey = false;
				colvarRFDate.IsReadOnly = false;
				colvarRFDate.DefaultSetting = @"";
				colvarRFDate.ForeignKeyTableName = "";
				schema.Columns.Add(colvarRFDate);
				
				TableSchema.TableColumn colvarTimeStart = new TableSchema.TableColumn(schema);
				colvarTimeStart.ColumnName = "TimeStart";
				colvarTimeStart.DataType = DbType.Int32;
				colvarTimeStart.MaxLength = 0;
				colvarTimeStart.AutoIncrement = false;
				colvarTimeStart.IsNullable = true;
				colvarTimeStart.IsPrimaryKey = false;
				colvarTimeStart.IsForeignKey = false;
				colvarTimeStart.IsReadOnly = false;
				colvarTimeStart.DefaultSetting = @"";
				colvarTimeStart.ForeignKeyTableName = "";
				schema.Columns.Add(colvarTimeStart);
				
				TableSchema.TableColumn colvarTimeEnd = new TableSchema.TableColumn(schema);
				colvarTimeEnd.ColumnName = "TimeEnd";
				colvarTimeEnd.DataType = DbType.Int32;
				colvarTimeEnd.MaxLength = 0;
				colvarTimeEnd.AutoIncrement = false;
				colvarTimeEnd.IsNullable = true;
				colvarTimeEnd.IsPrimaryKey = false;
				colvarTimeEnd.IsForeignKey = false;
				colvarTimeEnd.IsReadOnly = false;
				colvarTimeEnd.DefaultSetting = @"";
				colvarTimeEnd.ForeignKeyTableName = "";
				schema.Columns.Add(colvarTimeEnd);
				
				TableSchema.TableColumn colvarTimeStartFormatted = new TableSchema.TableColumn(schema);
				colvarTimeStartFormatted.ColumnName = "TimeStartFormatted";
				colvarTimeStartFormatted.DataType = DbType.String;
				colvarTimeStartFormatted.MaxLength = 10;
				colvarTimeStartFormatted.AutoIncrement = false;
				colvarTimeStartFormatted.IsNullable = true;
				colvarTimeStartFormatted.IsPrimaryKey = false;
				colvarTimeStartFormatted.IsForeignKey = false;
				colvarTimeStartFormatted.IsReadOnly = false;
				colvarTimeStartFormatted.DefaultSetting = @"";
				colvarTimeStartFormatted.ForeignKeyTableName = "";
				schema.Columns.Add(colvarTimeStartFormatted);
				
				TableSchema.TableColumn colvarTimeEndFormatted = new TableSchema.TableColumn(schema);
				colvarTimeEndFormatted.ColumnName = "TimeEndFormatted";
				colvarTimeEndFormatted.DataType = DbType.String;
				colvarTimeEndFormatted.MaxLength = 10;
				colvarTimeEndFormatted.AutoIncrement = false;
				colvarTimeEndFormatted.IsNullable = true;
				colvarTimeEndFormatted.IsPrimaryKey = false;
				colvarTimeEndFormatted.IsForeignKey = false;
				colvarTimeEndFormatted.IsReadOnly = false;
				colvarTimeEndFormatted.DefaultSetting = @"";
				colvarTimeEndFormatted.ForeignKeyTableName = "";
				schema.Columns.Add(colvarTimeEndFormatted);
				
				TableSchema.TableColumn colvarDuration = new TableSchema.TableColumn(schema);
				colvarDuration.ColumnName = "Duration";
				colvarDuration.DataType = DbType.Int32;
				colvarDuration.MaxLength = 0;
				colvarDuration.AutoIncrement = false;
				colvarDuration.IsNullable = true;
				colvarDuration.IsPrimaryKey = false;
				colvarDuration.IsForeignKey = false;
				colvarDuration.IsReadOnly = false;
				colvarDuration.DefaultSetting = @"";
				colvarDuration.ForeignKeyTableName = "";
				schema.Columns.Add(colvarDuration);
				
				TableSchema.TableColumn colvarTypology = new TableSchema.TableColumn(schema);
				colvarTypology.ColumnName = "Typology";
				colvarTypology.DataType = DbType.String;
				colvarTypology.MaxLength = 5;
				colvarTypology.AutoIncrement = false;
				colvarTypology.IsNullable = true;
				colvarTypology.IsPrimaryKey = false;
				colvarTypology.IsForeignKey = false;
				colvarTypology.IsReadOnly = false;
				colvarTypology.DefaultSetting = @"";
				colvarTypology.ForeignKeyTableName = "";
				schema.Columns.Add(colvarTypology);
				
				TableSchema.TableColumn colvarNominalCost = new TableSchema.TableColumn(schema);
				colvarNominalCost.ColumnName = "NominalCost";
				colvarNominalCost.DataType = DbType.Currency;
				colvarNominalCost.MaxLength = 0;
				colvarNominalCost.AutoIncrement = false;
				colvarNominalCost.IsNullable = true;
				colvarNominalCost.IsPrimaryKey = false;
				colvarNominalCost.IsForeignKey = false;
				colvarNominalCost.IsReadOnly = false;
				colvarNominalCost.DefaultSetting = @"";
				colvarNominalCost.ForeignKeyTableName = "";
				schema.Columns.Add(colvarNominalCost);
				
				TableSchema.TableColumn colvarRealCost = new TableSchema.TableColumn(schema);
				colvarRealCost.ColumnName = "RealCost";
				colvarRealCost.DataType = DbType.Currency;
				colvarRealCost.MaxLength = 0;
				colvarRealCost.AutoIncrement = false;
				colvarRealCost.IsNullable = true;
				colvarRealCost.IsPrimaryKey = false;
				colvarRealCost.IsForeignKey = false;
				colvarRealCost.IsReadOnly = false;
				colvarRealCost.DefaultSetting = @"";
				colvarRealCost.ForeignKeyTableName = "";
				schema.Columns.Add(colvarRealCost);
				
				TableSchema.TableColumn colvarEquivalentCost = new TableSchema.TableColumn(schema);
				colvarEquivalentCost.ColumnName = "EquivalentCost";
				colvarEquivalentCost.DataType = DbType.Currency;
				colvarEquivalentCost.MaxLength = 0;
				colvarEquivalentCost.AutoIncrement = false;
				colvarEquivalentCost.IsNullable = true;
				colvarEquivalentCost.IsPrimaryKey = false;
				colvarEquivalentCost.IsForeignKey = false;
				colvarEquivalentCost.IsReadOnly = false;
				colvarEquivalentCost.DefaultSetting = @"";
				colvarEquivalentCost.ForeignKeyTableName = "";
				schema.Columns.Add(colvarEquivalentCost);
				
				TableSchema.TableColumn colvarPositionInBreak = new TableSchema.TableColumn(schema);
				colvarPositionInBreak.ColumnName = "PositionInBreak";
				colvarPositionInBreak.DataType = DbType.Byte;
				colvarPositionInBreak.MaxLength = 0;
				colvarPositionInBreak.AutoIncrement = false;
				colvarPositionInBreak.IsNullable = true;
				colvarPositionInBreak.IsPrimaryKey = false;
				colvarPositionInBreak.IsForeignKey = false;
				colvarPositionInBreak.IsReadOnly = false;
				colvarPositionInBreak.DefaultSetting = @"";
				colvarPositionInBreak.ForeignKeyTableName = "";
				schema.Columns.Add(colvarPositionInBreak);
				
				TableSchema.TableColumn colvarNumberOfSpotsInBreak = new TableSchema.TableColumn(schema);
				colvarNumberOfSpotsInBreak.ColumnName = "NumberOfSpotsInBreak";
				colvarNumberOfSpotsInBreak.DataType = DbType.Byte;
				colvarNumberOfSpotsInBreak.MaxLength = 0;
				colvarNumberOfSpotsInBreak.AutoIncrement = false;
				colvarNumberOfSpotsInBreak.IsNullable = true;
				colvarNumberOfSpotsInBreak.IsPrimaryKey = false;
				colvarNumberOfSpotsInBreak.IsForeignKey = false;
				colvarNumberOfSpotsInBreak.IsReadOnly = false;
				colvarNumberOfSpotsInBreak.DefaultSetting = @"";
				colvarNumberOfSpotsInBreak.ForeignKeyTableName = "";
				schema.Columns.Add(colvarNumberOfSpotsInBreak);
				
				TableSchema.TableColumn colvarTypeOfSpot = new TableSchema.TableColumn(schema);
				colvarTypeOfSpot.ColumnName = "TypeOfSpot";
				colvarTypeOfSpot.DataType = DbType.Byte;
				colvarTypeOfSpot.MaxLength = 0;
				colvarTypeOfSpot.AutoIncrement = false;
				colvarTypeOfSpot.IsNullable = true;
				colvarTypeOfSpot.IsPrimaryKey = false;
				colvarTypeOfSpot.IsForeignKey = false;
				colvarTypeOfSpot.IsReadOnly = false;
				colvarTypeOfSpot.DefaultSetting = @"";
				colvarTypeOfSpot.ForeignKeyTableName = "";
				schema.Columns.Add(colvarTypeOfSpot);
				
				TableSchema.TableColumn colvarTypeOfBuyCode = new TableSchema.TableColumn(schema);
				colvarTypeOfBuyCode.ColumnName = "TypeOfBuyCode";
				colvarTypeOfBuyCode.DataType = DbType.Int32;
				colvarTypeOfBuyCode.MaxLength = 0;
				colvarTypeOfBuyCode.AutoIncrement = false;
				colvarTypeOfBuyCode.IsNullable = true;
				colvarTypeOfBuyCode.IsPrimaryKey = false;
				colvarTypeOfBuyCode.IsForeignKey = true;
				colvarTypeOfBuyCode.IsReadOnly = false;
				colvarTypeOfBuyCode.DefaultSetting = @"";
				
					colvarTypeOfBuyCode.ForeignKeyTableName = "TypeOfBuy";
				schema.Columns.Add(colvarTypeOfBuyCode);
				
				TableSchema.TableColumn colvarMediaCode = new TableSchema.TableColumn(schema);
				colvarMediaCode.ColumnName = "MediaCode";
				colvarMediaCode.DataType = DbType.Int32;
				colvarMediaCode.MaxLength = 0;
				colvarMediaCode.AutoIncrement = false;
				colvarMediaCode.IsNullable = true;
				colvarMediaCode.IsPrimaryKey = false;
				colvarMediaCode.IsForeignKey = true;
				colvarMediaCode.IsReadOnly = false;
				colvarMediaCode.DefaultSetting = @"";
				
					colvarMediaCode.ForeignKeyTableName = "Medium";
				schema.Columns.Add(colvarMediaCode);
				
				TableSchema.TableColumn colvarProgramCode = new TableSchema.TableColumn(schema);
				colvarProgramCode.ColumnName = "ProgramCode";
				colvarProgramCode.DataType = DbType.Int32;
				colvarProgramCode.MaxLength = 0;
				colvarProgramCode.AutoIncrement = false;
				colvarProgramCode.IsNullable = true;
				colvarProgramCode.IsPrimaryKey = false;
				colvarProgramCode.IsForeignKey = true;
				colvarProgramCode.IsReadOnly = false;
				colvarProgramCode.DefaultSetting = @"";
				
					colvarProgramCode.ForeignKeyTableName = "Program";
				schema.Columns.Add(colvarProgramCode);
				
				TableSchema.TableColumn colvarProductID = new TableSchema.TableColumn(schema);
				colvarProductID.ColumnName = "ProductID";
				colvarProductID.DataType = DbType.Int32;
				colvarProductID.MaxLength = 0;
				colvarProductID.AutoIncrement = false;
				colvarProductID.IsNullable = true;
				colvarProductID.IsPrimaryKey = false;
				colvarProductID.IsForeignKey = false;
				colvarProductID.IsReadOnly = false;
				colvarProductID.DefaultSetting = @"";
				colvarProductID.ForeignKeyTableName = "";
				schema.Columns.Add(colvarProductID);
				
				TableSchema.TableColumn colvarProdVersionID = new TableSchema.TableColumn(schema);
				colvarProdVersionID.ColumnName = "ProdVersionID";
				colvarProdVersionID.DataType = DbType.Int32;
				colvarProdVersionID.MaxLength = 0;
				colvarProdVersionID.AutoIncrement = false;
				colvarProdVersionID.IsNullable = true;
				colvarProdVersionID.IsPrimaryKey = false;
				colvarProdVersionID.IsForeignKey = false;
				colvarProdVersionID.IsReadOnly = false;
				colvarProdVersionID.DefaultSetting = @"";
				colvarProdVersionID.ForeignKeyTableName = "";
				schema.Columns.Add(colvarProdVersionID);
				
				TableSchema.TableColumn colvarCategoryID = new TableSchema.TableColumn(schema);
				colvarCategoryID.ColumnName = "CategoryID";
				colvarCategoryID.DataType = DbType.Int32;
				colvarCategoryID.MaxLength = 0;
				colvarCategoryID.AutoIncrement = false;
				colvarCategoryID.IsNullable = true;
				colvarCategoryID.IsPrimaryKey = false;
				colvarCategoryID.IsForeignKey = false;
				colvarCategoryID.IsReadOnly = false;
				colvarCategoryID.DefaultSetting = @"";
				colvarCategoryID.ForeignKeyTableName = "";
				schema.Columns.Add(colvarCategoryID);
				
				TableSchema.TableColumn colvarSectorID = new TableSchema.TableColumn(schema);
				colvarSectorID.ColumnName = "SectorID";
				colvarSectorID.DataType = DbType.Int32;
				colvarSectorID.MaxLength = 0;
				colvarSectorID.AutoIncrement = false;
				colvarSectorID.IsNullable = true;
				colvarSectorID.IsPrimaryKey = false;
				colvarSectorID.IsForeignKey = false;
				colvarSectorID.IsReadOnly = false;
				colvarSectorID.DefaultSetting = @"";
				colvarSectorID.ForeignKeyTableName = "";
				schema.Columns.Add(colvarSectorID);
				
				TableSchema.TableColumn colvarSubSectorID = new TableSchema.TableColumn(schema);
				colvarSubSectorID.ColumnName = "SubSectorID";
				colvarSubSectorID.DataType = DbType.Int32;
				colvarSubSectorID.MaxLength = 0;
				colvarSubSectorID.AutoIncrement = false;
				colvarSubSectorID.IsNullable = true;
				colvarSubSectorID.IsPrimaryKey = false;
				colvarSubSectorID.IsForeignKey = false;
				colvarSubSectorID.IsReadOnly = false;
				colvarSubSectorID.DefaultSetting = @"";
				colvarSubSectorID.ForeignKeyTableName = "";
				schema.Columns.Add(colvarSubSectorID);
				
				TableSchema.TableColumn colvarSubSector2ID = new TableSchema.TableColumn(schema);
				colvarSubSector2ID.ColumnName = "SubSector2ID";
				colvarSubSector2ID.DataType = DbType.Int32;
				colvarSubSector2ID.MaxLength = 0;
				colvarSubSector2ID.AutoIncrement = false;
				colvarSubSector2ID.IsNullable = true;
				colvarSubSector2ID.IsPrimaryKey = false;
				colvarSubSector2ID.IsForeignKey = false;
				colvarSubSector2ID.IsReadOnly = false;
				colvarSubSector2ID.DefaultSetting = @"";
				colvarSubSector2ID.ForeignKeyTableName = "";
				schema.Columns.Add(colvarSubSector2ID);
				
				TableSchema.TableColumn colvarBrandID = new TableSchema.TableColumn(schema);
				colvarBrandID.ColumnName = "BrandID";
				colvarBrandID.DataType = DbType.Int32;
				colvarBrandID.MaxLength = 0;
				colvarBrandID.AutoIncrement = false;
				colvarBrandID.IsNullable = true;
				colvarBrandID.IsPrimaryKey = false;
				colvarBrandID.IsForeignKey = false;
				colvarBrandID.IsReadOnly = false;
				colvarBrandID.DefaultSetting = @"";
				colvarBrandID.ForeignKeyTableName = "";
				schema.Columns.Add(colvarBrandID);
				
				TableSchema.TableColumn colvarAdvertiserID = new TableSchema.TableColumn(schema);
				colvarAdvertiserID.ColumnName = "AdvertiserID";
				colvarAdvertiserID.DataType = DbType.Int32;
				colvarAdvertiserID.MaxLength = 0;
				colvarAdvertiserID.AutoIncrement = false;
				colvarAdvertiserID.IsNullable = true;
				colvarAdvertiserID.IsPrimaryKey = false;
				colvarAdvertiserID.IsForeignKey = false;
				colvarAdvertiserID.IsReadOnly = false;
				colvarAdvertiserID.DefaultSetting = @"";
				colvarAdvertiserID.ForeignKeyTableName = "";
				schema.Columns.Add(colvarAdvertiserID);
				
				TableSchema.TableColumn colvarAgencyID = new TableSchema.TableColumn(schema);
				colvarAgencyID.ColumnName = "AgencyID";
				colvarAgencyID.DataType = DbType.Int32;
				colvarAgencyID.MaxLength = 0;
				colvarAgencyID.AutoIncrement = false;
				colvarAgencyID.IsNullable = true;
				colvarAgencyID.IsPrimaryKey = false;
				colvarAgencyID.IsForeignKey = false;
				colvarAgencyID.IsReadOnly = false;
				colvarAgencyID.DefaultSetting = @"";
				colvarAgencyID.ForeignKeyTableName = "";
				schema.Columns.Add(colvarAgencyID);
				
				TableSchema.TableColumn colvarDateAdded = new TableSchema.TableColumn(schema);
				colvarDateAdded.ColumnName = "DateAdded";
				colvarDateAdded.DataType = DbType.DateTime;
				colvarDateAdded.MaxLength = 0;
				colvarDateAdded.AutoIncrement = false;
				colvarDateAdded.IsNullable = false;
				colvarDateAdded.IsPrimaryKey = false;
				colvarDateAdded.IsForeignKey = false;
				colvarDateAdded.IsReadOnly = false;
				
						colvarDateAdded.DefaultSetting = @"(getdate())";
				colvarDateAdded.ForeignKeyTableName = "";
				schema.Columns.Add(colvarDateAdded);
				
				TableSchema.TableColumn colvarDateModified = new TableSchema.TableColumn(schema);
				colvarDateModified.ColumnName = "DateModified";
				colvarDateModified.DataType = DbType.DateTime;
				colvarDateModified.MaxLength = 0;
				colvarDateModified.AutoIncrement = false;
				colvarDateModified.IsNullable = false;
				colvarDateModified.IsPrimaryKey = false;
				colvarDateModified.IsForeignKey = false;
				colvarDateModified.IsReadOnly = false;
				
						colvarDateModified.DefaultSetting = @"(getdate())";
				colvarDateModified.ForeignKeyTableName = "";
				schema.Columns.Add(colvarDateModified);
				
				BaseSchema = schema;
				//add this schema to the provider
				//so we can query it later
				DataService.Providers["Adex"].AddSchema("CommercialLog",schema);
			}

		}

		#endregion
		
		#region Props
		
		  
		[XmlAttribute("CommercialLogID")]
		public long CommercialLogID 
		{
			get { return GetColumnValue<long>("CommercialLogID"); }

			set { SetColumnValue("CommercialLogID", value); }

		}

		  
		[XmlAttribute("CountryID")]
		public byte? CountryID 
		{
			get { return GetColumnValue<byte?>("CountryID"); }

			set { SetColumnValue("CountryID", value); }

		}

		  
		[XmlAttribute("RFDate")]
		public DateTime? RFDate 
		{
			get { return GetColumnValue<DateTime?>("RFDate"); }

			set { SetColumnValue("RFDate", value); }

		}

		  
		[XmlAttribute("TimeStart")]
		public int? TimeStart 
		{
			get { return GetColumnValue<int?>("TimeStart"); }

			set { SetColumnValue("TimeStart", value); }

		}

		  
		[XmlAttribute("TimeEnd")]
		public int? TimeEnd 
		{
			get { return GetColumnValue<int?>("TimeEnd"); }

			set { SetColumnValue("TimeEnd", value); }

		}

		  
		[XmlAttribute("TimeStartFormatted")]
		public string TimeStartFormatted 
		{
			get { return GetColumnValue<string>("TimeStartFormatted"); }

			set { SetColumnValue("TimeStartFormatted", value); }

		}

		  
		[XmlAttribute("TimeEndFormatted")]
		public string TimeEndFormatted 
		{
			get { return GetColumnValue<string>("TimeEndFormatted"); }

			set { SetColumnValue("TimeEndFormatted", value); }

		}

		  
		[XmlAttribute("Duration")]
		public int? Duration 
		{
			get { return GetColumnValue<int?>("Duration"); }

			set { SetColumnValue("Duration", value); }

		}

		  
		[XmlAttribute("Typology")]
		public string Typology 
		{
			get { return GetColumnValue<string>("Typology"); }

			set { SetColumnValue("Typology", value); }

		}

		  
		[XmlAttribute("NominalCost")]
		public decimal? NominalCost 
		{
			get { return GetColumnValue<decimal?>("NominalCost"); }

			set { SetColumnValue("NominalCost", value); }

		}

		  
		[XmlAttribute("RealCost")]
		public decimal? RealCost 
		{
			get { return GetColumnValue<decimal?>("RealCost"); }

			set { SetColumnValue("RealCost", value); }

		}

		  
		[XmlAttribute("EquivalentCost")]
		public decimal? EquivalentCost 
		{
			get { return GetColumnValue<decimal?>("EquivalentCost"); }

			set { SetColumnValue("EquivalentCost", value); }

		}

		  
		[XmlAttribute("PositionInBreak")]
		public byte? PositionInBreak 
		{
			get { return GetColumnValue<byte?>("PositionInBreak"); }

			set { SetColumnValue("PositionInBreak", value); }

		}

		  
		[XmlAttribute("NumberOfSpotsInBreak")]
		public byte? NumberOfSpotsInBreak 
		{
			get { return GetColumnValue<byte?>("NumberOfSpotsInBreak"); }

			set { SetColumnValue("NumberOfSpotsInBreak", value); }

		}

		  
		[XmlAttribute("TypeOfSpot")]
		public byte? TypeOfSpot 
		{
			get { return GetColumnValue<byte?>("TypeOfSpot"); }

			set { SetColumnValue("TypeOfSpot", value); }

		}

		  
		[XmlAttribute("TypeOfBuyCode")]
		public int? TypeOfBuyCode 
		{
			get { return GetColumnValue<int?>("TypeOfBuyCode"); }

			set { SetColumnValue("TypeOfBuyCode", value); }

		}

		  
		[XmlAttribute("MediaCode")]
		public int? MediaCode 
		{
			get { return GetColumnValue<int?>("MediaCode"); }

			set { SetColumnValue("MediaCode", value); }

		}

		  
		[XmlAttribute("ProgramCode")]
		public int? ProgramCode 
		{
			get { return GetColumnValue<int?>("ProgramCode"); }

			set { SetColumnValue("ProgramCode", value); }

		}

		  
		[XmlAttribute("ProductID")]
		public int? ProductID 
		{
			get { return GetColumnValue<int?>("ProductID"); }

			set { SetColumnValue("ProductID", value); }

		}

		  
		[XmlAttribute("ProdVersionID")]
		public int? ProdVersionID 
		{
			get { return GetColumnValue<int?>("ProdVersionID"); }

			set { SetColumnValue("ProdVersionID", value); }

		}

		  
		[XmlAttribute("CategoryID")]
		public int? CategoryID 
		{
			get { return GetColumnValue<int?>("CategoryID"); }

			set { SetColumnValue("CategoryID", value); }

		}

		  
		[XmlAttribute("SectorID")]
		public int? SectorID 
		{
			get { return GetColumnValue<int?>("SectorID"); }

			set { SetColumnValue("SectorID", value); }

		}

		  
		[XmlAttribute("SubSectorID")]
		public int? SubSectorID 
		{
			get { return GetColumnValue<int?>("SubSectorID"); }

			set { SetColumnValue("SubSectorID", value); }

		}

		  
		[XmlAttribute("SubSector2ID")]
		public int? SubSector2ID 
		{
			get { return GetColumnValue<int?>("SubSector2ID"); }

			set { SetColumnValue("SubSector2ID", value); }

		}

		  
		[XmlAttribute("BrandID")]
		public int? BrandID 
		{
			get { return GetColumnValue<int?>("BrandID"); }

			set { SetColumnValue("BrandID", value); }

		}

		  
		[XmlAttribute("AdvertiserID")]
		public int? AdvertiserID 
		{
			get { return GetColumnValue<int?>("AdvertiserID"); }

			set { SetColumnValue("AdvertiserID", value); }

		}

		  
		[XmlAttribute("AgencyID")]
		public int? AgencyID 
		{
			get { return GetColumnValue<int?>("AgencyID"); }

			set { SetColumnValue("AgencyID", value); }

		}

		  
		[XmlAttribute("DateAdded")]
		public DateTime DateAdded 
		{
			get { return GetColumnValue<DateTime>("DateAdded"); }

			set { SetColumnValue("DateAdded", value); }

		}

		  
		[XmlAttribute("DateModified")]
		public DateTime DateModified 
		{
			get { return GetColumnValue<DateTime>("DateModified"); }

			set { SetColumnValue("DateModified", value); }

		}

		
		#endregion
		
		
			
		
		#region ForeignKey Properties
		
		/// <summary>
		/// Returns a Country ActiveRecord object related to this CommercialLog
		/// 
		/// </summary>
		public Adex.Country Country
		{
			get { return Adex.Country.FetchByID(this.CountryID); }

			set { SetColumnValue("CountryID", value.CountryID); }

		}

		
		
		/// <summary>
		/// Returns a Medium ActiveRecord object related to this CommercialLog
		/// 
		/// </summary>
		public Adex.Medium Medium
		{
			get { return Adex.Medium.FetchByID(this.MediaCode); }

			set { SetColumnValue("MediaCode", value.MediaCode); }

		}

		
		
		/// <summary>
		/// Returns a Program ActiveRecord object related to this CommercialLog
		/// 
		/// </summary>
		public Adex.Program Program
		{
			get { return Adex.Program.FetchByID(this.ProgramCode); }

			set { SetColumnValue("ProgramCode", value.ProgramCode); }

		}

		
		
		/// <summary>
		/// Returns a TypeOfBuy ActiveRecord object related to this CommercialLog
		/// 
		/// </summary>
		public Adex.TypeOfBuy TypeOfBuy
		{
			get { return Adex.TypeOfBuy.FetchByID(this.TypeOfBuyCode); }

			set { SetColumnValue("TypeOfBuyCode", value.TypeOfBuyCode); }

		}

		
		
		#endregion
		
		
		
		//no ManyToMany tables defined (0)
		
		#region ObjectDataSource support
		
		
		/// <summary>
		/// Inserts a record, can be used with the Object Data Source
		/// </summary>
		public static void Insert(byte? varCountryID,DateTime? varRFDate,int? varTimeStart,int? varTimeEnd,string varTimeStartFormatted,string varTimeEndFormatted,int? varDuration,string varTypology,decimal? varNominalCost,decimal? varRealCost,decimal? varEquivalentCost,byte? varPositionInBreak,byte? varNumberOfSpotsInBreak,byte? varTypeOfSpot,int? varTypeOfBuyCode,int? varMediaCode,int? varProgramCode,int? varProductID,int? varProdVersionID,int? varCategoryID,int? varSectorID,int? varSubSectorID,int? varSubSector2ID,int? varBrandID,int? varAdvertiserID,int? varAgencyID,DateTime varDateAdded,DateTime varDateModified)
		{
			CommercialLog item = new CommercialLog();
			
			item.CountryID = varCountryID;
			
			item.RFDate = varRFDate;
			
			item.TimeStart = varTimeStart;
			
			item.TimeEnd = varTimeEnd;
			
			item.TimeStartFormatted = varTimeStartFormatted;
			
			item.TimeEndFormatted = varTimeEndFormatted;
			
			item.Duration = varDuration;
			
			item.Typology = varTypology;
			
			item.NominalCost = varNominalCost;
			
			item.RealCost = varRealCost;
			
			item.EquivalentCost = varEquivalentCost;
			
			item.PositionInBreak = varPositionInBreak;
			
			item.NumberOfSpotsInBreak = varNumberOfSpotsInBreak;
			
			item.TypeOfSpot = varTypeOfSpot;
			
			item.TypeOfBuyCode = varTypeOfBuyCode;
			
			item.MediaCode = varMediaCode;
			
			item.ProgramCode = varProgramCode;
			
			item.ProductID = varProductID;
			
			item.ProdVersionID = varProdVersionID;
			
			item.CategoryID = varCategoryID;
			
			item.SectorID = varSectorID;
			
			item.SubSectorID = varSubSectorID;
			
			item.SubSector2ID = varSubSector2ID;
			
			item.BrandID = varBrandID;
			
			item.AdvertiserID = varAdvertiserID;
			
			item.AgencyID = varAgencyID;
			
			item.DateAdded = varDateAdded;
			
			item.DateModified = varDateModified;
			
		
			if (System.Web.HttpContext.Current != null)
				item.Save(System.Web.HttpContext.Current.User.Identity.Name);
			else
				item.Save(System.Threading.Thread.CurrentPrincipal.Identity.Name);
		}

		
		/// <summary>
		/// Updates a record, can be used with the Object Data Source
		/// </summary>
		public static void Update(long varCommercialLogID,byte? varCountryID,DateTime? varRFDate,int? varTimeStart,int? varTimeEnd,string varTimeStartFormatted,string varTimeEndFormatted,int? varDuration,string varTypology,decimal? varNominalCost,decimal? varRealCost,decimal? varEquivalentCost,byte? varPositionInBreak,byte? varNumberOfSpotsInBreak,byte? varTypeOfSpot,int? varTypeOfBuyCode,int? varMediaCode,int? varProgramCode,int? varProductID,int? varProdVersionID,int? varCategoryID,int? varSectorID,int? varSubSectorID,int? varSubSector2ID,int? varBrandID,int? varAdvertiserID,int? varAgencyID,DateTime varDateAdded,DateTime varDateModified)
		{
			CommercialLog item = new CommercialLog();
			
				item.CommercialLogID = varCommercialLogID;
				
				item.CountryID = varCountryID;
				
				item.RFDate = varRFDate;
				
				item.TimeStart = varTimeStart;
				
				item.TimeEnd = varTimeEnd;
				
				item.TimeStartFormatted = varTimeStartFormatted;
				
				item.TimeEndFormatted = varTimeEndFormatted;
				
				item.Duration = varDuration;
				
				item.Typology = varTypology;
				
				item.NominalCost = varNominalCost;
				
				item.RealCost = varRealCost;
				
				item.EquivalentCost = varEquivalentCost;
				
				item.PositionInBreak = varPositionInBreak;
				
				item.NumberOfSpotsInBreak = varNumberOfSpotsInBreak;
				
				item.TypeOfSpot = varTypeOfSpot;
				
				item.TypeOfBuyCode = varTypeOfBuyCode;
				
				item.MediaCode = varMediaCode;
				
				item.ProgramCode = varProgramCode;
				
				item.ProductID = varProductID;
				
				item.ProdVersionID = varProdVersionID;
				
				item.CategoryID = varCategoryID;
				
				item.SectorID = varSectorID;
				
				item.SubSectorID = varSubSectorID;
				
				item.SubSector2ID = varSubSector2ID;
				
				item.BrandID = varBrandID;
				
				item.AdvertiserID = varAdvertiserID;
				
				item.AgencyID = varAgencyID;
				
				item.DateAdded = varDateAdded;
				
				item.DateModified = varDateModified;
				
			item.IsNew = false;
			if (System.Web.HttpContext.Current != null)
				item.Save(System.Web.HttpContext.Current.User.Identity.Name);
			else
				item.Save(System.Threading.Thread.CurrentPrincipal.Identity.Name);
		}

		#endregion
		#region Columns Struct
		public struct Columns
		{
			 public static string CommercialLogID = @"CommercialLogID";
			 public static string CountryID = @"CountryID";
			 public static string RFDate = @"RFDate";
			 public static string TimeStart = @"TimeStart";
			 public static string TimeEnd = @"TimeEnd";
			 public static string TimeStartFormatted = @"TimeStartFormatted";
			 public static string TimeEndFormatted = @"TimeEndFormatted";
			 public static string Duration = @"Duration";
			 public static string Typology = @"Typology";
			 public static string NominalCost = @"NominalCost";
			 public static string RealCost = @"RealCost";
			 public static string EquivalentCost = @"EquivalentCost";
			 public static string PositionInBreak = @"PositionInBreak";
			 public static string NumberOfSpotsInBreak = @"NumberOfSpotsInBreak";
			 public static string TypeOfSpot = @"TypeOfSpot";
			 public static string TypeOfBuyCode = @"TypeOfBuyCode";
			 public static string MediaCode = @"MediaCode";
			 public static string ProgramCode = @"ProgramCode";
			 public static string ProductID = @"ProductID";
			 public static string ProdVersionID = @"ProdVersionID";
			 public static string CategoryID = @"CategoryID";
			 public static string SectorID = @"SectorID";
			 public static string SubSectorID = @"SubSectorID";
			 public static string SubSector2ID = @"SubSector2ID";
			 public static string BrandID = @"BrandID";
			 public static string AdvertiserID = @"AdvertiserID";
			 public static string AgencyID = @"AgencyID";
			 public static string DateAdded = @"DateAdded";
			 public static string DateModified = @"DateModified";
						
		}

		#endregion
	}

}

